<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <title>Title</title>
    <div th:replace="common/links::header"></div>
    <div th:replace="common/script::js_footer"></div>
    <script th:src="@{/js/common/verify.js}"></script>
</head>
<body class="form-body">
<form class="layui-form ">
    <input type="hidden" name="id" th:value="${sysMenu.id}">
    <input type="hidden" name="parentId" id="parentId" th:value="${sysMenu.parentId}">
    <div class="layui-form-item layui-col-md6 layui-col-md-offset2">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-inline form-length350">
            <input type="text" name="name" th:value="${sysMenu.name}" lay-verify="required|menuName" placeholder="请输入名称" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">*2-12个字符</div>
    </div>
    <div class="layui-form-item layui-col-md4 layui-col-md-offset2">
        <label class="layui-form-label">上级</label>
        <div class="layui-input-inline">
            <input type="text" name="parentNodeName" id="parentNodeName" th:value="${sysMenu.parentNode.name}" value="" lay-verify="required"   placeholder="请选择上级节点" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">*请选择上级节点</div>
    </div>
    <div class="layui-form-item layui-col-md4 layui-col-md-offset2">
        <label class="layui-form-label">url</label>
        <div class="layui-input-inline">
            <input type="text" name="path" th:value="${sysMenu.path}"  placeholder="请输入url"
                   autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">*菜单路径</div>
    </div>
    <div class="layui-form-item layui-col-md4 layui-col-md-offset2">
        <label class="layui-form-label">icon</label>
        <div class="layui-input-inline" >
            <input type="text" name="icon" th:value="${sysMenu.icon}"
                   placeholder="菜单图标" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">菜单图标</div>
    </div>
     <div class="layui-form-item layui-col-md4 layui-col-md-offset2">
         <label class="layui-form-label">code</label>
         <div class="layui-input-inline" >
             <input type="text" name="code" th:value="${sysMenu.code}"
                    placeholder="权限标识" autocomplete="off" class="layui-input">
         </div>
         <div class="layui-form-mid layui-word-aux">权限标识</div>
     </div>
     <div class="layui-form-item">
         <div class="layui-col-md4 layui-col-md-offset2">
             <label class="layui-form-label">类型</label>
             <div class="layui-input-inline">
                 <input type="radio" name="menuType" value="1" title="菜单"  th:checked="${sysMenu.menuType == '1'}">
                 <input type="radio" name="menuType" value="2" title="权限"  th:checked="${sysMenu.menuType == '2'}">
             </div>
         </div>
     </div>
    <div class="layui-form-item">
        <div class="layui-col-md4 layui-col-md-offset2">
            <label class="layui-form-label">排序号</label>
            <div class="layui-input-inline">
                <input type="number" name="sortNo" th:value="${sysMenu.sortNo}"
                       placeholder="排序号" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-col-md-offset5">
        <div class="layui-input-block">
            <button class="layui-btn" shiro:hasPermission="sys:menu:basic:op" lay-submit="" lay-filter="add">立即提交</button>
            <button id="closeBtn" type="button" class="layui-btn layui-btn-primary">取消</button>
        </div>
    </div>
</form>
<script type="text/javascript" th:inline="javascript">
    layui.use('form', function () {
        var form = layui.form;
        form.render();
        //监听提交
        form.on('submit(add)', function (data) {
            Common.ajaxFormSubmit('/sys/menu/save-or-update', data.field, function (data) {
                layer.msg(data.msg,{icon:6},function () {
                    Common.closeFrame();
                });
            });
            return false;
        });
        $("#parentNodeName").on('click',function () {
            Common.openFrame('/sys/menu/tree','请选择父节点','400px','500px',null);
        })
        $("#closeBtn").on('click',function () {
            Common.closeFrame();
        });
    });

    function chooseParent(node) {
        $("#parentNodeName").val(node.name);
        $("#parentId").val(node.id);
    }

</script>
</body>
</html>